package com.tql.mall.merchant.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tql.mall.merchant.mapper.ShopInfoMapper;
import com.tql.mall.merchant.service.ShopInfoService;
import com.tql.mall.model.merchant.ShopInfo;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService {
    @Override
    public Boolean updateShop(ShopInfo shopInfo) {
        ShopInfo shopInfo1 = baseMapper.selectById(shopInfo.getId());
        if (shopInfo1 == null) return false;
        shopInfo.setUpdateTime(new Date());
        baseMapper.updateById(shopInfo);
        return true;
    }

    @Override
    public Boolean updateStatus(Long id, Integer status) {
        ShopInfo shopInfo = baseMapper.selectById(id);
        if (shopInfo == null) return false;
        shopInfo.setStatus(status);
        int i = baseMapper.updateById(shopInfo);
        if (i > 0) return true;
        return false;
    }
}
